<template>
  <div>
    <el-tree
        :data="data"
        show-checkbox
        node-key="id"
        :props="defaultProps"
        @check="getids"
    />
  </div>
</template>

<script>
import myaxios from 'axios'

export default {
  name: "user_bu",
  data() {
    return {
      data: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  methods: {
    getaudit(){
      //读取公司部门角色列表
      myaxios({url:'http://127.0.0.1:5000/getcomanyuser', method:'get'})
          .then(res=>{
            this.data = res.data.list
          })

    },
    getids(val1, status) {
      this.checkdvalues = []
      let list = status['checkedNodes']
      for (var i = 0; i < list.length; i++) {
        if (list[i]['type'] == 3) {
          this.checkdvalues.push(list[i]['id'])
          alert(this.checkdvalues)
        }
      }
      this.$emit('setids',this.checkdvalues)
    },
  },
  mounted() {
    this.getaudit()
  }
}
</script>

<style scoped>

</style>